package com.grad.webstudy.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.grad.webstudy.constants.CourseTypeConstants;

import java.io.Serializable;
import java.util.Date;

public class CourseType implements Serializable {
    private Integer id;

    private String typeName;

    private Integer parentId = CourseTypeConstants.PARENT_ID;


    private String creator;

    @JsonFormat( pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    private int type;

    public CourseType(Builder builder) {
        this.id = builder.id;
        this.typeName = builder.typeName;
        this.parentId = builder.parentId;
        this.creator = builder.creator;
        this.createTime = builder.createTime;
        this.type = builder.type;
    }


    @Override
    public String toString() {
        return "CourseType{" +
                "id=" + id +
                ", typeName='" + typeName + '\'' +
                ", parentId=" + parentId +
                ", creator='" + creator + '\'' +
                ", createTime=" + createTime +
                ", type=" + type +
                '}';
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parendId) {
        this.parentId = parendId;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName == null ? null : typeName.trim();
    }


    public CourseType() {
    }



    public static class Builder {
        private Integer id;

        private String typeName;

        private Integer parentId = CourseTypeConstants.PARENT_ID;


        private String creator;

        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date createTime;

        private int type;


        public Builder setId(Integer id) {
            this.id = id;
            return this;
        }

        public Builder setTypeName(String typeName) {
            this.typeName = typeName;
            return this;
        }

        public Builder setParentId(Integer parentId) {
            this.parentId = parentId;
            return this;
        }

        public Builder setCreator(String creator) {
            this.creator = creator;
            return this;
        }

        public Builder setCreateTime(Date createTime) {
            this.createTime = createTime;
            return this;
        }

        public Builder setType(int type) {
            this.type = type;
            return this;
        }


        public CourseType build() {
            return new CourseType(this);
        }
    }
}